package com.zkx.blogweb.mapper.service;

import com.zkx.blogweb.entity.User;
import com.zkx.blogweb.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author zkx
 */
@Transactional
@Service
public class UserMapperImp {
    @Autowired
    UserMapper userMapper;
    //查询数据库的
    public User getUser(Integer blogId){
        return userMapper.selectByBlog(blogId);
    }

    /**
     * 得到所有的blog,包括管理员
     */
    public int blogerNums(){
        return userMapper.selectNums();
    }

    /**
     *
     *
     */
    public void insertSelective(User user){
        userMapper.insertSelective(user);
    }

    /**
     * 根据用户号查询用户
     */
    public User selectByUserId(Integer id){
        return userMapper.selectByPrimaryKey(id);
    }

    public void updateInfo(User user) {
        userMapper.updateByPrimaryKeySelective(user);
    }

    public void deleteById(Integer userId) {
        userMapper.deleteByPrimaryKey(userId);
    }


}
